package com.bugsnag.ohos.reactnative;


import com.bugsnag.ohos.DateUtils;
import com.bugsnag.ohos.DeviceWithState;

import java.util.Arrays;
import java.util.Map;

public class DeviceSerializer implements MapSerializer<DeviceWithState> {
    @Override
    public void serialize(Map<String, Object> map, DeviceWithState device) {
        map.put("cpuAbi", Arrays.stream(device.getCpuAbi()).toArray());
        map.put("jailbroken", device.jailbroken);
        map.put("id", device.id);
        map.put("locale", device.locale);
        map.put("manufacturer", device.manufacturer);
        map.put("model", device.model);
        map.put("osName", device.osName);
        map.put("osVersion", device.osVersion);
        map.put("totalMemory", device.totalMemory);
        map.put("freeDisk", device.freeDisk);
        map.put("freeMemory", device.freeMemory);
        map.put("orientation", device.orientation);
        if (device.time != null) {
            map.put("time", DateUtils.toIso8601(device.time));
        }
        map.put("runtimeVersions", device.runtimeVersions);
    }
}
